<?php

class BelongsToAssociation extends Association
{

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/domain/Association#loadData($client)
   */
  protected function loadData(IAggregate $client)
  {
    $dao = DAO::getInstance();

    $table = $this->getDefinition()->getTarget()->getTable();
    $fk = $this->getDefinition()->getForeignKeyField()->getName();
    $pk = $this->getDefinition()->getPrimaryKey();

    $id = $client->get($pk);

    $result = $dao->query()->from($table)->where("$fk = ?")->execute($id);

    $obj = DomainMapper::inflateObj($this->getDefinition()->getTarget(), $result->fetchRow());

    $meta = & $this->data($client);
    $meta['value'] = $obj;
  }

}

?>